//
//  NYLoveCell.swift
//  SheYangBigData
//
//  Created by 宋海胜 on 2020/12/30.
//  Copyright © 2020 叁拾叁. All rights reserved.
//

import UIKit

class NYLoveCell: SYBaseCell {

    let nameLb: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x333333)
        v.font = 13.autoFontSize()
        
        return v
    }()
    
    let timeLb: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x333333)
        v.font = 10.autoFontSize()
        
        return v
    }()
    
    let header: UIImageView = {
        let v: UIImageView = UIImageView()
        v.layer.cornerRadius = 20.0.autoWidth()
        v.clipsToBounds = true
        return v
    }()
    
    let love: UIImageView = {
        let v: UIImageView = UIImageView()
        v.layer.cornerRadius = 9.0.autoWidth()
        v.image = UIImage(named: "zan")
        return v
    }()
    
    let tuPian: UIImageView = {
        let v: UIImageView = UIImageView()
        v.layer.cornerRadius = 3.0.autoWidth()
        v.clipsToBounds = true
        return v
    }()

    public func configureView(_ model: PYDianzanListModel) {
        if let d = model.updateDate {
            timeLb.text =  d
             
        } else if let d = model.createDate {
            timeLb.text =  d
        }
        nameLb.text = model.appUser?.trueName
        tuPian.kf.setImage(with: (model.imgUrl ?? "").sy_imageURL())
        header.kf.setImage(with: (model.appUser?.headImg ?? "").sy_imageURL())
    }
    
    override func initViews() {
        
        addSubview(header)
        addSubview(nameLb)
        addSubview(timeLb)
        addSubview(love)
        addSubview(tuPian)
        addSubview(lineView)
        header.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(17.5.autoWidth())
            make.left.equalToSuperview().offset(autoWidth(15.0))
            make.width.equalTo(40.0.autoWidth())
            make.height.equalTo(40.0.autoWidth())
        }
        nameLb.snp.makeConstraints { (make) in
            make.top.equalTo(header.snp.top)
            make.left.equalTo(header.snp.right).offset(autoWidth(13.0))
            make.width.equalTo(100.0.autoWidth())
            make.height.equalTo(13.0.autoWidth())
        }
        love.snp.makeConstraints { (make) in
            make.top.equalTo(nameLb.snp.bottom).offset(autoWidth(15.5))
            make.left.equalTo(nameLb.snp.left)
            make.width.height.equalTo(18.0.autoWidth())
        }
        timeLb.snp.makeConstraints { (make) in
            make.top.equalTo(love.snp.bottom).offset(autoWidth(15.5))
            make.height.equalTo(16.0.autoWidth())
            make.left.equalTo(nameLb.snp.left)
            make.width.equalTo(200.0.autoWidth())
            make.bottom.equalToSuperview().offset(autoWidth(-15.0))
        }
        tuPian.snp.makeConstraints { (make) in
            make.top.equalTo(header.snp.top)
            make.right.equalToSuperview().offset(autoWidth(-15.0))
            make.width.equalTo(71.0.autoWidth())
            make.height.equalTo(71.0.autoWidth())
        }
        lineView.snp.makeConstraints { (make) in
            make.bottom.equalToSuperview()
            make.left.equalToSuperview().offset(autoWidth(15.0))
            make.right.equalToSuperview().offset(autoWidth(-15.0))
            make.height.equalTo(0.5.autoWidth())
        }
    }
}
